﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GurLoader.Preferences
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks>
    /// Excluded from code coverage as all operations are directly dependent on the underlying .Net framework impl.
    /// </remarks>
    [ExcludeFromCodeCoverage]
    public class LocalIOFileOperations : IFileOperations
    {
        public string GetDirectoryName(string fileName)
        {
            return Path.GetDirectoryName(fileName);
        }

        public bool DirectoryExists(string directory)
        {
            return Directory.Exists(directory);
        }

        public void CreateDirectory(string directory)
        {
            Directory.CreateDirectory(directory);
        }

        public void WriteAllText(string fileName, string data)
        {
            File.WriteAllText(fileName, data);
        }

        public bool FileExists(string fileName)
        {
            return File.Exists(fileName);
        }

        public string ReadAllText(string fileName)
        {
            return File.ReadAllText(fileName);
        }

        public string GetTempFileName()
        {
            return Path.GetTempFileName();
        }

        public void DeleteFile(string filename)
        {
            File.Delete(filename);
        }
    }
}
